<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        body{
            text-align: center;
            background-image: url("imgs/bg.jpg");
            margin: 0;/*去掉自带外边距*/
            background-size: cover;/*cove  把背景图片设置为封面  设置之后  背景图片 不会随着浏览器缩放而缩放 会自动填充 */
            background-repeat: no-repeat;/*背景图片不重复*/
        }
        h1{
            font-size: 72px;
            color: #0096dc;
            margin-bottom: 0;
        }
        h2 {
            font-size: 32px;
            color: #0096dc;
            margin-bottom: 0;
        }
    </style>
</head>
<body>
<div id="app">
    <h1>欢迎来到酷鲨停车场</h1>
    <img src="imgs/shark.png">
    <h2>CoolSharkParking</h2>
    <el-card style="width: 600px;height: 300px;margin: 0 auto;
    background-color: rgba(255,255,255,0.3)">
        <!--label-width设置文本所占的宽度如果不设置,文本单独显示一行-->
        <el-form label-width="60px" style="width: 400px;margin: 50px auto">
            <el-form-item label="用户名">
                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="user.password" placeholder="请输入密码"></el-input>
            </el-form-item>
            <el-form-item STYLE="position: relative;left: 140px">
                <el-button type="primary" @click="submitForm('ruleForm')">登录</el-button>
                <el-button @click="resetForm('ruleForm')">注册</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                ruleForm: {
                    name: '',
                    password: '',
                },
                rules: {
                    name: [
                        { required: true, message: '请输入用户名', trigger: 'blur' },
                        { min: 4, max: 15, message: '长度在 4 到 15 个字符', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        { min: 4, max: 15, message: '长度在 4 到 15 个字符', trigger: 'blur' }
                    ],
                }
            }
        },
        methods:{
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        alert('请求参数格式验证通过!');
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    })
</script>
</html>